var UserCrops = require("UserCrops");
var Controller = require("Controller");
cc.Class({
    extends: cc.Component,

    properties: {
        userCrops : UserCrops,
        pic : cc.Sprite,
        controller : Controller,
        ui_time : cc.Label,
        cur_stage : 0,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    //start () {

    //},

    // update (dt) {},
    init(){
        var m_stage = this.controller.calcStage(this.userCrops,this.controller.m_crops);
        this.cur_stage = m_stage[1];
        this.ui_time.string = "0/0";
        var path = m_stage[0].picture;
        cc.loader.loadRes(path,function(err,spriteFrame){  
            this.pic.spriteFrame=new cc.SpriteFrame(spriteFrame);
        }.bind(this));
        //this.pic.spriteFrame = new cc.SpriteFrame(cc.url.raw(path));
        this.node.on(cc.Node.EventType.TOUCH_END,function(t){
            this.controller.ui_choose.active = true;
            this.controller.ui_choose.setPosition(t.touch.getLocation());
            this.controller.choose_crops = this.node;
        },this);
    },
});
